package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IDispatchEngineeringInstallationOrderView;
import com.cloudsigns.factorymanager2.engineering.IView.IDispatchEngineeringOrderListView;
import com.cloudsigns.factorymanager2.engineering.IView.ILoginView;
import com.cloudsigns.factorymanager2.engineering.model.DispatchEngineeringInstallationOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.IDispatchEngineeringInstallationOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.ILoginModel;
import com.cloudsigns.factorymanager2.engineering.model.LoginModel;

/**
 * Created by tony on 2018/3/23.
 */

public class DispatchEngineeringInstallationOrderPresenter {
    private IDispatchEngineeringInstallationOrderView view;
    private IDispatchEngineeringInstallationOrderModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public DispatchEngineeringInstallationOrderPresenter(IDispatchEngineeringInstallationOrderView view) {
        this.view = view;
        this.model = new DispatchEngineeringInstallationOrderModel();
    }

    public void dispatchEngineeringInstallationOrder() {


        model.dispatchEngineeringInstallationOrder(view.getId(), view.getReceiveAccountId(), new DispatchEngineeringInstallationOrderModel.OnDispatchEngineeringInstallationOrderListener() {
            @Override
            public void successed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.diapatchSuccess();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.showFailedError(desc);
                        view.hideLoading();
                    }
                });
            }
        });

    }

}
